home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / swing < prev    next >
Text File  |  1995-03-31  |  25KB  |  496 lines

  1. Article 4991 of comp.sys.handhelds:
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!kth.se!news
  3. From: lennartb@lne.kth.se (Lennart Brjeson @ KTH, Stockholm)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: SWING for HP48
  6. Message-ID: <00945812.A9A51100@lne.kth.se>
  7. Date: 12 Mar 91 15:47:11 GMT
  8. Sender: news@kth.se  (News Administrator)
  9. Reply-To: lennartb@lne.kth.se (Lennart Brjeson @ KTH, Stockholm)
  10. Organization: KTH, Royal Institute of Technology, School of Electrical Engineering
  11. Lines: 481
  12.  
  13. **HP48**
  14.  
  15. This is SWING for the HP48. SWING was named after an old PD utility for VMS.
  16. SWING draws a tree representing your entire directory structure and lets
  17. you walk around in it using the cursor key. SWING "precompiles" the tree so
  18. it can be redrawn easily, this means that you must execute the SWSAVE routine
  19. anytime you have created or deleted directories if the SWING tree is to be
  20. correct. SWING is written in user RPL but I myself find the speed acceptable.
  21. SWING must be installed as a library (or be placed in the HOME directory) in
  22. order to work. Exit SWING by pressing ENTER, this will change your path to
  23. the one indicated. RUBOUT (key 55) quits without changing the path.
  24. SWING is assigned library 1644, BTW.
  25.  
  26. Library and source follows.
  27.  
  28. The library in ASC format:
  29. --Cut here-----------------------------
  30. %%HP: T(3)A(D)F(.);
  31. "04B201171011357594E47402269702C456E6E61627472411C664100000000DC0
  32. 002A610E4A20EB00000000000000000064000E40006700000000000000000000
  33. 00000000000000000000000000000000005000404524C44430050357594E4740
  34. 005035757454452005074C424C44440060357535146554100E30006100093000
  35. A500043000E4A20F50001600039100872004F20053300F46000770029800F690
  36. 0DF900B701098210A0310DD310C74103C41035510B75108C66000D9D20E16323
  37. CE22491A14563284E204005051425976324BAC1AFE22D9D2084E204005051425
  38. 9C2A2387C147A2084E204005051425DCC02B213076BA1B21305BF2247A2047A2
  39. 084E204005051425B2130EFE02B21305DF2229E20C66500521A1779200000000
  40. 000000000000000000000000029E20C669003FBF1E0CF1A59C18DBF1EB3A13CE
  41. 22AFE22EB3A15BF228DBF15DF2293632B21308C66100D9D20E1632521A1041A1
  42. 29E20C66300E4A2051000000000000000000078BF12ABF129E20C66400E4A205
  43. 1000040000000000000029E20C66010DBBF1E4A2051000380000000000000029
  44. E20C66010DBBF13F2A2387C14563284E2090357796E6764416471697632DCC02
  45. EB3A193632B21308C66200D9D20E1632FD33284E2090357796E67644164716F1
  46. 732D9D208DBF129E20C6610029E20C66200B21305BF22D9D20B7FC18DBF1B213
  47. 05DF2293632B21308C66300D9D20E1632521A147A20041A1B213029E20C66700
  48. DBBF1EB3A193632B2130000C66400D9D20E16321C432D6E2020D687D6E2020D6
  49. 97D6E201087D6E201097E1632B7FC18DBF1DBBF178BF19C2A2387C1B0BC13F2A
  50. 292CF18B9C1ED2A290DA1C58C1D6E201087D6E201097ED2A2387C1DBBF13F2A2
  51. 387C178BF13F2A26C7D129E20C668008B9C1D6E20109776BA1D6E2020D69729E
  52. 20C6601045632D6E2020D69797632DCC02D6E20108776BA1803A276BA145632D
  53. 6E20108797632DCC02D6E201087D6E2020D68729E20C6601045632D6E2020D68
  54. 797632DCC02DBBF1B7FC11C432D6E201037E16323CE22D6E201037AFE22D9D20
  55. 9C2A2D6E20103730132D6E2010375BCF1D6E2010375BCF1ED2A2387C1D6E2020
  56. D687D6E2020D697D6E201087D6E20109729E20C66400D6E2020D69729E20C660
  57. 1045632D6E2020D69797632DCC02D6E2020D68729E20C6601045632D6E2020D6
  58. 8797632DCC02D6E2020D69745632D6E20109797632DCC0247A20B2130ED2A208
  59. 33247A20B21309C2A2D6E2010373013276BA1C4232B21305BF2247A20B21305D
  60. F229C2A2387C176BA1EF532D6E2020D687D6E2020D697EF53293632B2130D9D2
  61. 0E163229E20C662002ABF1614E1634E1DCC02BB6919C2A290DA14B2A2DBBF1E9
  62. 7C1DBBF1BB6919C2A290DA14B2A2E97C1ED2A2387C147A2084E2010854B2A277
  63. 92000000000000000000000000000000000166E184E201095B213076BA145632
  64. 84E20400505142597632DCC02743A24A5A177920000000000000000000000000
  65. 000000000F2E129E20C6660093632B2130D9D20E1632A59C11C432D6E201037E
  66. 16323CE22D6E201037AFE22D9D209C2A2D6E20103730132D6E2010375BCF1D6E
  67. 2010375BCF1A72E1D6E2010375BCF12ABF1634E1E0CF1E0CF129E20C66800AE8
  68. C192CF129E20C66D00D6E2010375BCF129E20C66600803A208332D6E2010379C
  69. 2A290DA1A9CF1803A2A9CF129E20C66C00B21305DF22D6E201037387C1EF5329
  70. 3632B2130D9D20E163278BF1EB3A1339201000000000000510FA1A11C432D6E2
  71. 01067E163247A20B21304B2A2D6E2010678B9C10A132D6E2010963CE22D6E201
  72. 096AFE22D9D20D6E201067D6E20109678BF1C58C129E20C6670076BA1B21305D
  73. F22C42329C2A2387C176BA1EF532B51A193632B2130D9D20E16329C2A2DA5E17
  74. 8BF18B9C19C2A276BA1DBBF19C2A276BA1DBBF1614E147A20E4A205100010000
  75. 00000000000E4A20510001000000000000000B2130E0CF1AE8C193632B2130D9
  76. D20E1632DBBF178BF19C2A29C2A2C58C1DBBF1ED2A292CF18B9C1C58C14B2A27
  77. 8BF11C432D6E201046D6E20200767D6E2020C613D6E2020C623D6E201027D6E2
  78. 01056E16323C032D6E201046D6E2020C613B7FC18DBF14BAC178BF11C432D6E2
  79. 01007D6E20200707E16323C0323CE22D6E2020C6238B9C1AFE22D9D20D6E2010
  80. 46D6E2010073F2A276BA16C7D1D6E2020C623D6E2020076729E20C6690045632
  81. D6E2020076797632DCC023CE2278BF1F88E1AFE22D9D203FBF14B2A278BF1B21
  82. 305DF2245632D6E20105697632DCC0245632D6E20102797632DCC0245632D6E2
  83. 020C62397632DCC02B21305BF22D9D20634E1D6E201046D6E2010077C8D14563
  84. 2D6E2020C613976329C2A2E0CF1704D17C8D1E0CF1E0CF16C7D129E20C668005
  85. 99A1D6E2020076729E20C66A0045632D6E2020076797632DCC024B2A2F17A1D6
  86. BB11C432D6E2010B6E1632D8732D9D20D6E2010B633920100000000000052016
  87. 7E1D6E2010B6339201000000000000530167E1908E18A732D9D20D6E2010B633
  88. 920100000000000003090DA1D13A250FA1803A2EEDA1D6E20100776BA19C2A29
  89. 0DA1D6E2010468B9C1D4EB19C2A276BA145632D6E2020070797632DCC02B2130
  90. 5DF22D6E2010B6339201000000000000430167E18A732D9D2047A20B21304563
  91. 2D6E2020C61397632DCC029C2A245632D6E20102797632DCC02B21305DF22D6E
  92. 2010B6339201000000000000630167E18A732D9D20D6E201046D6E2010073F2A
  93. 276BA16C7D19C2A278BF1C58C145632D6E2020C62397632DCC02B21305DF22D6
  94. E2010B6339201000000000000150167E18A732D9D209C2A245632D6E20102797
  95. 632DCC029C2A245632D6E20105697632DCC02B21305DF22D6E2010B633920100
  96. 0000000000550167E18A732D9D209C2A245632D6E20105697632DCC02B21305D
  97. F223392030000000000420103392099900000000005204C5A1B21305DF22EF53
  98. 2634E1D6E201046D6E2010079C2A276BA17C8D1E0CF1E0CF16C7D129E20C6680
  99. 0AE8C1D6E2020070745632D6E20100797632DCC02B21305DF22DE032D6E20102
  100. 7D6E201056908E19B632EF532DE032D6E201027D6E201056908E19B632D6E202
  101. 0C613D6E2020C62376BA1D6E201027D6E201056D6E20200767EF53293632B213
  102. 0D9D20E1632E89C11C432D6E20200787D6E20200797E1632E0CF13F2A2A9CF13
  103. F2A2A9CF1AE8C18B9C1E0CF1E89C11C432D6E201077D6E201086D6E20207687D
  104. 6E20207697E163247A20EBBE1B2130D6E2020768745632D6E202007879763229
  105. E20C66B0047A20EBBE1B2130D6E2020769745632D6E202007979763229E20C66
  106. B0047A20D5CE1B2130D6E20207687D6E201077BB69176BA1803A276BA1339202
  107. 00000000000131090DA145632D6E202007879763229E20C66B0047A20D5CE1B2
  108. 130D6E20207697D6E201086BB69176BA133920100000000000046090DA145632
  109. D6E202007979763229E20C66B00D6E20200787D6E20200797E97C178BF10F2E1
  110. EF532EF53293632B2130D9D20E16321C432D6E2010E6D6E201067E16323CE22D
  111. 6E2010E6D6E201067EB3A1E0CF1EB3A1AFE22D9D20D6E2010E6D6E201067DCC0
  112. 2B21305DF22EF53293632B2130D9D20E16323CE2278BF1E89C18DBF1AFE22D9D
  113. 20779200000000000000039000000000000002076BA1DBBF178BF17792000000
  114. 00000000049000000000000002076BA1A13E1779200000000000000039000000
  115. 000000002076BA1893E1B21305BF223FBF15DF2293632B2130D9D20E16323CE2
  116. 278BF1E89C18DBF1AFE22D9D2077920000000000000002900000000000000207
  117. 6BA178BF1779200000000000000019000000000000000076BA1893E1B21305BF
  118. 228DBF15DF2293632B213047A2029E20C6600029E20C6650029E20C6610029E2
  119. 0C6620029E20C6630029E20C66400B213047A207792000000000000005690000
  120. 000000000139779200000000000000560000000000000023084E2010854B2A27
  121. 792000000000000000000000000000000000166E184E201095B2130D9D20E163
  122. 2BB691DBBF1BB69117CB1B969193632B2130D9D20E1632339203000000000044
  123. 6108441293632B2130EC755EA0"
  124. --Cut here-----------------------------
  125.  
  126. The source directory:
  127. --Cut here-----------------------------
  128. %%HP: T(3)A(D)F(.);
  129. DIR
  130.   SWING @ Main routine. No arguments.
  131.     \<<
  132.       IF VARS 'PPAR' POS        @ Check for existence of PPAR
  133.       THEN                      @ PPAR exits, save it in post-swing procedure
  134.         PPAR 1 \->LIST { PPAR STO } +
  135.       ELSE                      @ doesn't exist, purge it in post-swing proc.
  136.         { { PPAR } PURGE }
  137.       END
  138.       SHOWDIR                   @ Draw tree
  139.       PATH (0,0) SWSUB          @ Start interaction at current path
  140.       DROP2 ROT LIST\-> DROP EVAL @ Drop position, execute post-swing procedure
  141.       IF                        @ If normal exit, change path, else drop it
  142.       THEN EVAL
  143.       ELSE DROP
  144.       END
  145.     \>>
  146.   SWSAVE @ Pre-compile tree. No arguments.
  147.     \<< 
  148.       PATH HOME                 @ Save current path, goto HOME
  149.       TBLD                      @ Build list of directories
  150.       # 0h DUP DUP2 GLBLD       @ Convert list to graphic list
  151.       # 40h MAXB SWAP           @ PICT must be at least 131x64
  152.       # 83h MAXB SWAP
  153.       3 \->LIST 'SwingData' STO @ Save in SwingData
  154.       EVAL                      @ Return to old path
  155.     \>>
  156.   SWGET @ Get SwingData. No arguments.
  157.     \<<
  158.       IFERR SwingData           @ Check existence of SwingData
  159.       THEN DROP SWSAVE SWGET    @ If not, create
  160.       ELSE OBJ\-> DROP          @ Exists, extract graphic list and PICT size
  161.       END
  162.     \>>
  163.   TBLD @ Build directory table (list). No arguments.
  164.     \<<
  165.       PATH                      @ Save current path
  166.       { HOME } RBLD             @ Start at HOME, call recursive builder
  167.       SWAP EVAL                 @ Restore path
  168.     \>>
  169.   GLBLD @ Graphic list builder. 
  170.         @ Directory list = {[Dirname Directory_list_of_subdirs]...}
  171.         @ Inputs: 5: Directory table from TBLD
  172.         @         4: Max x, so far (binary)
  173.         @         3: Max y, so far (binary)
  174.         @         2: x position (binary)
  175.         @         1: y position (binary)
  176.         @ Outputs:3: Graphic list
  177.         @         2: Max x
  178.         @         1: Max y
  179.         @ Graphic list = {[Dirname Dirpos Dirstr graphiclist_of_subdirs]...}
  180.     \<< \-> mx my x y
  181.       \<< OBJ\-> DROP           @ The HOME directory table has only one entry,
  182.                                 @ GLBLD will call itself with one-entry-lists
  183.                                 @ only, so we can drop the size.
  184.  
  185.                                 @ To convert Dirname to a GROB, we can't just
  186.                                 @ do \->GROB, since HOME \->STR will result
  187.                                 @ in "HOME", but FOOBAR \->STR will result in
  188.                                 @ "'FOOBAR'". The current workaround is to
  189.                                 @ put the name in a list, convert the list to
  190.                                 @ a string and to extract the relevant part.
  191.          SWAP DUP 1 \->LIST     @ Put Dirname into a list
  192.          \->STR                 @ Convert to string
  193.          3 OVER SIZE 2 - SUB    @ Extract "Dirname", i.e. Dirstr
  194.          x y 2 \->LIST          @ Make the coord {x y}, i.e. Dirpos
  195.          SWAP 3 \->LIST         @ Make {Dirname Dirpos Dirstr}
  196.          DUP 3 GET EGROB SIZE   @ Get size of the GROB of Dirstr
  197.          y + my MAXB 'my' STO   @ Update maximum y
  198.          x + 4 + 'x' STO        @ Update x
  199.          x mx MAXB 'mx' STO     @ Update maximum x
  200.          SWAP OBJ\-> \-> s      @ Explode directory_list_of_subdirs
  201.         \<<
  202.           IF s                  @ If any subdirs at all...
  203.           THEN 1 s              @ ...loop over all subdirs
  204.             START s ROLL s ROLL @ Get next subdir 
  205.             2 \->LIST           @ Make it a one-entry subdir_list
  206.             mx my x y GLBLD     @ Call GLBLD recursively
  207.             my MAXB 'my' STO    @ Update maximum y
  208.             mx MAXB 'mx' STO    @ Update maximum x
  209.             my 'y' STO          @ Update y
  210.             { } 2               @ Dummy list to keep stack depth, loop step
  211.             STEP { } 1 s        @ Concatenate the s graphic_subdir_lists
  212.             START +             @ on the stack
  213.             NEXT
  214.           ELSE { }              @ No subdirs, return empty list
  215.           END 1 \->LIST +       @ Make {Dirname Dirpos Dirstr subdir_list}
  216.         \>> mx my               @ Return cuurent maximum x and y
  217.       \>>
  218.     \>>
  219.   SHOWDIR @ Draws the tree. No arguments.
  220.     \<<
  221.       SWGET                             @ Get SwingData
  222.       DUP2 BLANK PICT STO               @ Set size of PICT
  223.       B\->R 1 - 0 SWAP R\->C            @ Lower left corner in user coords
  224.       SWAP B\->R 1 - 0 R\->C            @ Upper right in user coords
  225.       2 \->LIST { X 0 (0,0)             @ Make new PPAR
  226.       FUNCTION Y } + 'PPAR' STO
  227.       7 FREEZE                          @ Freeze display so we don't get clock!
  228.       (0,0) PVIEW SHWSUB                @ Show PICT and call SHWSUB
  229.     \>>
  230.   SHWSUB @ Recursive tree drawer.
  231.          @ Input: 1: Graphic list.
  232.          @ Graphic list = {[Dirname Dirpos Dirstr graphiclist_of_subdirs]...}
  233.          @ Output:1: Graphic list. (Pos changed to user coords.)
  234.     \<<
  235.       LIST\-> \-> s                     @ Explode list
  236.       \<<
  237.         IF s                            @ If non-empty list...
  238.         THEN 1 s                        @ ...walk through all elements
  239.           START s ROLL s ROLL           @ Get Dirname and Dirpos
  240.             PX\->C                      @ Convert Dirpos to user coord
  241.             s ROLL DUP2                 @ Get Dirstr, save Dirpos_u and Dirstr
  242.             PICT ROT ROT EGROB          @ Make PICT Dirpos_u DirGROB
  243.             REPL                        @ Put GROB in PICT
  244.             OVER DRAWTAG                @ Draw a small horizontal tag at Dirpos
  245.             s ROLL SHWSUB               @ Get subdir_list and draw it recurs.
  246.             4                           @ Loop step
  247.           STEP
  248.           s 1 - PICK                    @ Get pos of first subdir
  249.           4 PICK                        @ Get pos of last subdir
  250.           DRAWBAR                       @ Draw vertical bar from 1:st to last
  251.         END s \->LIST                   @ Rebuild Graphic list
  252.       \>>
  253.     \>>
  254.   RBLD @ Recursive builder.
  255.        @ Input: 1: Single directory name.
  256.        @ Output: 1: Directory list.
  257.        @ Directory list = {[Dirname Directory_list_of_subdirs]...}
  258.     \<< DUP                             @ Save directory name
  259.       EVAL                              @ Enter directory
  260.       15 TVARS \-> v                    @ Get list of subdirs
  261.       \<< { } 0 v SIZE                  @ Loop over all subdirs
  262.         FOR i
  263.           IF i                          @ If any subdir
  264.           THEN v i DUP SUB              @ Get subdir # i
  265.             RBLD                        @ Call builder recursively
  266.             +                           @ Concatenate list
  267.           END
  268.         NEXT 1 \->LIST                  @ Make subdir_list
  269.         +                               @ Make {Dirname subdir_list}
  270.       \>> UPDIR                         @ Return to directory above
  271.     \>>
  272.   EGROB @ Extended GROB. Same as 1 \->GROB, only the grob is extended
  273.         @ one row above and one column on the right.
  274.         @ Input: 1: Any.
  275.         @ Output: 1: Grob.
  276.     \<<
  277.       1 \->GROB                         @ Make original grob
  278.       DUP SIZE 1 + SWAP 1 + SWAP        @ Get size + 1
  279.       BLANK { # 1h # 1h } ROT REPL      @ Extend grob
  280.     \>>
  281.   SWSUB @ The interactive swing subroutine which traverses the tree.
  282.         @ One complicating fact is that we may have to 'pan' the PICT around
  283.         @ if it is bigger than the screen. The first-level argument keeps track
  284.         @ of the current point to PVIEW.
  285.         @ Inputs: 3: Graphic list
  286.         @         2: Path of directory to traverse to
  287.         @         1: PVIEW point
  288.         @ Outputs:4: Updated path
  289.         @         3: return-flag
  290.         @         2: exit-flag
  291.         @         1: Updated PVIEW point
  292.     \<< SWAP                            @ Get path
  293.       DUP 1 1 SUB                       @ Get {1:st-dir-in-path}
  294.       SWAP 2 OVER SIZE SUB              @ Get {rest-of-path}
  295.       0 DUP \-> d pv l1 l2 r e          @ Save gr_list, pview_point,
  296.                                         @  sublist1, sublist2, 
  297.                                         @  and init return-flag and exit-flag
  298.                                         @ sublist1 is always 1 element long
  299.                                         @ sublist2 is the subpath that remains
  300.                                         @  to be traversed
  301.                                         @ return-flag and exit-flag are used
  302.                                         @  as follows:
  303.                                         @ r | e | meaning
  304.                                         @ ---------------
  305.                                         @ 0 | 0 | Continue on current level
  306.                                         @ 0 | 1 | Exit all, don't set path
  307.                                         @ 1 | 0 | Exit current level only
  308.                                         @ 1 | 1 | Exit all, set path
  309.                                         
  310.       \<<
  311.         DO d                            @ graphic list
  312.           l1 OBJ\-> DROP                @ get 1:st dir in path
  313.           POS                           @ find position in graphic list
  314.           DUP \-> p pp                  @ save in p and pp
  315.           \<<
  316.             DO                          @ Do while not (exit or return)
  317.               IF l2 SIZE                @ Are there dirs left in path?
  318.               THEN                      @ Yes, traverse down in tree
  319.                 d p 3 + GET             @ Get graphic list of subdir
  320.                 l2 pv                   @ Get subpath and pview point
  321.                 SWSUB                   @ Call SWSUB recursively
  322.                 'pv' STO                @ Update pview point
  323.                 IF DUP NOT              @ If not exit-flag...
  324.                 THEN DROP2 0 DUP        @ ...then don't exit further
  325.                 END 'e' STO             @ Update exit-flag
  326.                 'r' STO                 @ Update return-flag
  327.                 'l2' STO                @ Update subpath
  328.               ELSE                      @ No, reverse (black) cur. dir in tree
  329.                 PICT                    @ PICT on stack
  330.                 d p GETI                @ Put current Dirname...
  331.                 'l1' 1 ROT PUT          @ ... in sublist1
  332.                 GETI                    @ Get current Dirpos...
  333.                 ROT ROT GET             @ ... and current Dirstr
  334.                 EGROB NEG               @ Make a reversed GROB of the Dirstr
  335.                 pv SWREPL               @ SWREPL is like REPL, but it also
  336.                                         @  pans PICT if any part the current
  337.                                         @  dir is invisible
  338.                 'pv' STO                @ Update PVIEW point
  339.                 0 WAIT                  @ Wait for keypress
  340.                 IP \-> k                @ Save key code in k
  341.                 \<<
  342.                   CASE
  343.                     k 25 SAME           @ If 'Up'- or...
  344.                     k 35 SAME OR        @ 'Down'-key 
  345.                     THEN k 30 - 5 / 4 * @ -4 if 'Up', +4 if 'Down'
  346.                       p +               @ New p
  347.                       1 - d SIZE MOD 1 +@ Wrap around
  348.                       'pp' STO          @ Save new p in pp
  349.                     END
  350.                     k 34 SAME           @ If 'Left'-key
  351.                     THEN { } 'l1' STO   @ Blank out sublist1
  352.                                         @  (Sublist2 is already empty,
  353.                                         @  so this will make the current
  354.                                         @  subpath empty - which will make
  355.                                         @  SWSUB remain at the level above
  356.                                         @  the current.)
  357.                       1 'r' STO         @ Set return-flag
  358.                     END
  359.                     k 36 SAME           @ If 'Right'-key
  360.                     THEN d p 3 + GET    @ Get graphic list of subdirs
  361.                       1 DUP SUB         @ Get 1:st subdir
  362.                       'l2' STO          @ Save in sublist2 (Which will make
  363.                                         @  SWSUB to traverse down one level
  364.                                         @  in the next loop)
  365.                     END
  366.                     k 51 SAME           @ If 'Enter'-key
  367.                     THEN 1 'r' STO      @ Set return-flag and...
  368.                       1 'e' STO         @ ...and exit-flag
  369.                     END
  370.                     k 55 SAME           @ If 'RubOut'-key
  371.                     THEN 1 'e' STO      @ Set exit-flag
  372.                     END
  373.                     1024 .25 BEEP       @ Beep on all other keys
  374.                   END                   @ End of CASE
  375.                 \>>                     @ Exit, key dispatch, render dir normal
  376.                 PICT                    @ Save PICT on stack
  377.                 d p 1 + GETI            @ Get current Dirpos...
  378.                 ROT ROT GET             @ ...and Dirstr
  379.                 EGROB REPL              @ Make a GROB and put it in PICT
  380.                 pp 'p' STO              @ Update new p
  381.               END                       @ END of IF any subdirs
  382.             UNTIL r e OR                @ Exit if return or exit
  383.             END
  384.           \>>
  385.         UNTIL r e OR                    @ Exit if return or exit
  386.         END l1 l2 + r e pv              @ Exit SWSUB, return path,
  387.                                         @  return-flag, exit-flag and
  388.                                         @  current PVIEW point
  389.       \>>
  390.     \>>
  391.   SWREPL @ SWREPL is like REPL, but it will also pan PICT if any part of
  392.          @ the current dir is invisible.
  393.          @ Inputs: 4: PICT
  394.          @         3: coord
  395.          @         2: GROB
  396.          @         1: PVIEW point
  397.          @ Output: 1: New PVIEW point
  398.     \<< C\->R \-> px py                 @ Explode PVIEW point
  399.       \<< ROT 3 PICK 3 PICK REPL        @ Save coor and GROB, do REPL
  400.         SIZE                            @ Get size of GROB
  401.         ROT C\->R                       @ Explode coord
  402.         \-> w h gx gy                   @ Save width and height and coords
  403.         \<< { < } gx 'px' SWCLIP        @ Clip on left edge of screen
  404.           { < } gy 'py' SWCLIP          @ Clip on top edge of screen
  405.           { > }
  406.           gx w B\->R + 4 + 131 -        @ Right limit of GROB
  407.           'px' SWCLIP                   @ Clip on right edge of edge
  408.           { > }
  409.           gy h B\->R + 64 -             @ Bottom limit of GROB
  410.           'py' SWCLIP                   @ Clip on bottom edge of screen
  411.           px py R\->C                   @ New PVIEW point
  412.           DUP PVIEW                     @ Save it on stack, do PVIEW
  413.         \>>
  414.       \>>
  415.     \>>
  416.   SWCLIP @ Clips a variable to a value
  417.          @ Inputs: 3: Condition operator
  418.          @         2: Value number
  419.          @         1: Variable name
  420.          @ No output.
  421.     \<< \-> n v                         @ Save number and variable
  422.       \<<
  423.         IF
  424.           n                             @ Get number
  425.           v EVAL                        @ Get value in variable
  426.           ROT EVAL                      @ Evaluate condition
  427.         THEN n v STO                    @ If true, store new value
  428.         END
  429.       \>>
  430.     \>>
  431.   DRAWBAR @ Draws a line between two directory positions
  432.           @ (The bar is always vertical, from the first to the last
  433.           @  subdirectory)
  434.           @ Inputs: 2: Coord of first subdir
  435.           @         1: Coord of last subdir
  436.           @ No output.
  437.     \<<
  438.       IF DUP C\->R DROP                 @ If x coord nonzero then...
  439.       THEN (-3,2) +                     @ Offset last pos
  440.         SWAP DUP                        @ Get and save first pos
  441.         (-4,2) + PIXON                  @ Extend the tag at 1:st dir
  442.         (-3,2) +                        @ Offset last pos
  443.         LINE                            @ Draw the bar
  444.       ELSE DROP2                        @ ...else do nothing
  445.       END
  446.     \>>
  447.   DRAWTAG @ Draws a short tag at the left of a directory
  448.           @ Input: 1: Coord of dir
  449.           @ No output.
  450.     \<<
  451.       IF DUP C\->R DROP                 @ If x coord nonzero then...
  452.       THEN (-2,2) +                     @ Offset start position
  453.         DUP (-1,0) +                    @ Offset stop position
  454.         LINE                            @ Draw the tag
  455.       ELSE DROP                         @ ...else do nothing
  456.       END
  457.     \>>
  458.   CST @ Custom menu. Not included in library.
  459.     { SWING SHOWDIR SWSAVE SWGET TBLD GLBLD }
  460.   PPAR @ Default PPAR. Not included in library.
  461.     { (-6.5,-3.1) (6.5,3.2) X 0 (0,0) FUNCTION Y }
  462.   MAXB @ Maximum of binaries.
  463.        @ Inputs: 2: Binary
  464.        @         1: Binary
  465.        @ Output: 1: Max binary.
  466.     \<< B\->R SWAP B\->R MAX R\->B
  467.     \>>
  468.   $TITLE "SWING by LennartB"
  469.   $VISIBLE { SWING SWSAVE SWGET TBLD GLBLD }
  470.   $CONFIG
  471.     \<< 1644 ATTACH
  472.     \>>
  473.   $ROMID 1644
  474.   $VARS { CST PPAR SwingData }
  475. END
  476. --Cut here-----------------------------
  477.  
  478. !++
  479. ! Lennart Boerjeson, System Manager
  480. ! School of Electrical Engineering
  481. ! Royal Institute of Technology
  482. ! S-100 44 Stockholm, Sweden
  483. ! tel: int+46-8-7907814
  484. ! Internet: lennartb@lne.kth.se
  485. !--
  486. !++
  487. ! Lennart Boerjeson, System Manager
  488. ! School of Electrical Engineering
  489. ! Royal Institute of Technology
  490. ! S-100 44 Stockholm, Sweden
  491. ! tel: int+46-8-7907814
  492. ! Internet: lennartb@lne.kth.se
  493. !--
  494.  
  495.  
  496.